package com.muyu.system.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.system.domain.DanmoShoppingReviews;
import com.muyu.system.service.IDanmoShoppingReviewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 产品评论Controller
 *
 * @author yangle
 * @date 2024-09-29
 */
@RestController
@RequestMapping("/reviews")
public class DanmoShoppingReviewsController extends BaseController
{
    @Autowired
    private IDanmoShoppingReviewsService danmoShoppingReviewsService;

    /**
     * 查询产品评论列表
     */
//    @RequiresPermissions("system:reviews:list")
    @PostMapping("/list")
    public Result list(@RequestBody DanmoShoppingReviews danmoShoppingReviews)
    {
        return danmoShoppingReviewsService.selectDanmoShoppingReviewsList(danmoShoppingReviews);
    }

    /**
     * 导出产品评论列表
     */
//    @RequiresPermissions("system:reviews:export")
/*    @Log(title = "产品评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoShoppingReviews danmoShoppingReviews)
    {
        List<DanmoShoppingReviews> list = danmoShoppingReviewsService.selectDanmoShoppingReviewsList(danmoShoppingReviews);
        ExcelUtil<DanmoShoppingReviews> util = new ExcelUtil<DanmoShoppingReviews>(DanmoShoppingReviews.class);
        util.exportExcel(response, list, "产品评论数据");
    }*/

    /**
     * 获取产品评论详细信息
     */
//    @RequiresPermissions("system:reviews:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoShoppingReviewsService.selectDanmoShoppingReviewsById(id));
    }

    /**
     * 新增产品评论
     */
//    @RequiresPermissions("system:reviews:add")
    @Log(title = "产品评论", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoShoppingReviews danmoShoppingReviews)
    {
        return toAjax(danmoShoppingReviewsService.insertDanmoShoppingReviews(danmoShoppingReviews));
    }

    /**
     * 修改产品评论
     */
//    @RequiresPermissions("system:reviews:edit")
    @Log(title = "产品评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoShoppingReviews danmoShoppingReviews)
    {
        return toAjax(danmoShoppingReviewsService.updateDanmoShoppingReviews(danmoShoppingReviews));
    }

    /**
     * 删除产品评论
     */
//    @RequiresPermissions("system:reviews:remove")
    @Log(title = "产品评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoShoppingReviewsService.deleteDanmoShoppingReviewsByIds(ids));
    }
}
